package com.dk.goodnight.service;

import com.dk.goodnight.dao.UserDao;
import com.dk.goodnight.model.TokenBean;
import com.dk.goodnight.model.UserBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements IUserService {

    @Resource
    private UserDao userDao;

    @Override
    public UserBean getUserByPhone(String phone) {
        return userDao.getUserByPhone(phone);
    }

    @Override
    public int register(UserBean userBean) {
        userDao.register(userBean);
        return userBean.getUser_id();
    }

    @Override
    public int insertToken(TokenBean tokenBean) {
        userDao.insertToken(tokenBean);
        return tokenBean.getId();
    }

    @Override
    public int updateUserInfo(UserBean userBean) {
        userDao.updateUserInfo(userBean);
        return userBean.getUser_id();
    }

    @Override
    public UserBean getUserInfo(int user_id) {
        return userDao.getUserInfo(user_id);
    }
}
